<?php


namespace api\modules\v1\controllers\statistics;

use api\controllers\OnAuthController;
use services\clinic\UserSurplusService;
use services\patient\DrugSurplusService;
use Yii;

class ClinicController extends OnAuthController
{
    /**
     * @var string
     */
    public $modelClass = '';

    /**
     * @api {get} /v1/statistics/clinic/project-list 治疗项目列表
     * @apiName project-list
     * @apiGroup Clinic
     *
     *
     * @apiSuccess {Object}  data                                   返回数据
     */
    public function actionProjectList()
    {
        $params = Yii::$app->request->get();

        $userService = new DrugSurplusService();
        $data = $userService->getReportProjectList();

        return $data;
    }

    /**
     * @api {get} /v1/statistics/clinic/drug-user-list 输液药品患者列表
     * @apiName drug-user-list
     * @apiGroup Clinic
     *
     * @apiParam {Number} id                            药品配置ID
     * @apiParam {String} keywords                      关键词【姓名or诊疗号】
     * @apiParam {String} clinic_id                     诊室ID
     * @apiParam {String} min_num                       剩余数量最小值
     * @apiParam {String} max_num                       剩余数量最大值
     * @apiParam {Number} page                          页码
     * @apiParam {Number} pageSize                      每页显示数量
     *
     * @apiSuccess {Object}  data                                   返回数据
     */
    public function actionDrugUserList()
    {
        $params = Yii::$app->request->get();

        $id = $params['id'] ?? 0;
        $page = $params['page'] ?? 1;
        $pageSize = $params['pageSize'] ?? 10;

        $userService = new DrugSurplusService();
        $data = $userService->getReportUserList($params, (int)$id, (int)$page, (int)$pageSize);

        return $data;
    }

    /**
     * @api {get} /v1/statistics/clinic/treament-user-list 治疗项目患者列表
     * @apiName treament-user-list
     * @apiGroup Clinic
     *
     * @apiParam {Number} id                            治疗项目ID
     * @apiParam {String} keywords                      关键词【姓名or诊疗号】
     * @apiParam {String} clinic_id                     诊室ID
     * @apiParam {String} min_num                       剩余数量最小值
     * @apiParam {String} max_num                       剩余数量最大值
     * @apiParam {Number} page                          页码
     * @apiParam {Number} pageSize                      每页显示数量
     *
     * @apiSuccess {Object}  data                                   返回数据
     */
    public function actionTreamentUserList()
    {
        $params = Yii::$app->request->get();

        $id = $params['id'] ?? 0;
        $page = $params['page'] ?? 1;
        $pageSize = $params['pageSize'] ?? 10;

        $userService = new UserSurplusService();
        $data = $userService->getReportUserList($params, (int)$id, (int)$page, (int)$pageSize);

        return $data;
    }
}